package com.metaera.app.controller.presenter;

import com.metaera.app.controller.core.RequestPresenter;
import com.metaera.app.controller.view.core.INetworkRequestView;
import com.metaera.app.data.DataRepository;
import com.metaera.app.data.model.UserNoticeResponse;
import com.metaera.app.data.rx.ResponseObserver;
import com.metaera.app.data.rx.SchedulersTransformer;

public class EditUserNoticePresenter extends RequestPresenter<INetworkRequestView<Object>> {

    private final int id;

    public EditUserNoticePresenter(int id) {
        this.id = id;
    }

    public void notice(boolean isNotice) {
        DataRepository.getInstance()
                .updateUserNotice(id,isNotice ? "1" : "0", null, null, null,
                        null, null, null, null)
                .compose(SchedulersTransformer.transformer())
                .subscribe(new ResponseObserver<>(
                                this,
                                mView,
                                response -> mView.successful(response.getData())
                        )
                );
    }

    public void flash(boolean isNotice) {
        DataRepository.getInstance()
                .updateUserNotice(id,null, null, null, null,
                        null, isNotice ? "1" : "0", null, null)
                .compose(SchedulersTransformer.transformer())
                .subscribe(new ResponseObserver<>(
                                this,
                                mView,
                                response -> mView.successful(response.getData())
                        )
                );
    }

    public void article(boolean isNotice) {
        DataRepository.getInstance()
                .updateUserNotice(id,null, null, null, null,
                        isNotice ? "1" : "0", null, null, null)
                .compose(SchedulersTransformer.transformer())
                .subscribe(new ResponseObserver<>(
                                this,
                                mView,
                                response -> mView.successful(response.getData())
                        )
                );
    }

    public void center(boolean isNotice) {
        DataRepository.getInstance()
                .updateUserNotice(id,null, null, null, null,
                        null, null, isNotice ? "1" : "0", null)
                .compose(SchedulersTransformer.transformer())
                .subscribe(new ResponseObserver<>(
                                this,
                                mView,
                                response -> mView.successful(response.getData())
                        )
                );
    }
}
